config = `pkg-config gtkmm-2.4 gconf-2.0 --libs --cflags`
object = main_win.o main_notebook.o gconf_notebook.o proc_view.o net_view.o
lib_object = system.o proc_list.o gconf.o net_list.o
lib_sysctl = network.o filesystem.o kernel.o vm.o

all:linux-helper-sysctl linux-helper
	
linux-helper:linux-helper-sysctl main.cpp gui lib_object
	g++ main.cpp $(object) $(lib_object) -o linux-helper $(config)

linux-helper-sysctl:sysctl kernel_notebook sysctl_win
	g++ linux-helper-sysctl.cpp kernel_notebook.o sysctl_win.o $(lib_sysctl) -o linux-helper-sysctl  $(config)
	
gui:main_win main_notebook net_view proc_view gconf_notebook

lib_object:net_list proc_list gconf sysctl

sysctl:network filesystem kernel vm system

network:
	g++ -c ./sysctl/network.cpp

filesystem:
	g++ -c ./sysctl/filesystem.cpp
	
system:
	g++ -c ./sysctl/system.cpp
	
kernel:
	g++ -c ./sysctl/kernel.cpp

vm:
	g++ -c ./sysctl/vm.cpp

net_list:
	g++ -c ./lib/net_list.cpp

gconf:
	g++ -c ./lib/gconf.cpp `pkg-config gconf-2.0 --libs --cflags`

proc_list:
	g++ -c ./lib/proc_list.cpp
	
main_win:
	g++ -c ./ui/main_win.cpp $(config)

sysctl_win:
	g++ -c ./ui/sysctl_win.cpp $(config)
	
main_notebook:
	g++ -c ./ui/main_notebook.cpp $(config)

kernel_notebook:sysctl
	g++ -c ./ui/kernel_notebook.cpp $(config)

gconf_notebook:gconf
	g++ -c ./ui/gconf_notebook.cpp $(config)

net_view:
	g++ -c ./ui/net_view.cpp $(config)

proc_view:
	g++ -c ./ui/proc_view.cpp $(config)


.PHONY:clean install uninstall

install:
	mkdir -p /usr/share/linux-helper
	mkdir -p /usr/share/linux-helper/icon
	cp ./linux-helper ./linux-helper-sysctl ./misc/linux-helper.glade ./misc/linux-helper-sysctl.glade /usr/share/linux-helper
	install -m644 ./icon/*.png /usr/share/linux-helper/icon
	install -m644 ./misc/linux-helper.desktop /usr/share/applications/
	install -m644 ./misc/linux-helper-sysctl.pam /etc/pam.d/linux-helper-sysctl
	install -m644 ./misc/linux-helper-sysctl.console.app /etc/security/console.apps/linux-helper-sysctl
	chmod a+x /usr/share/linux-helper/linux-helper
	ln -s consolehelper /usr/bin/linux-helper-sysctl

uninstall:
	rm -rf /usr/share/linux-helper/icon/*.*
	rm -rf /usr/share/linux-helper/icon
	rm -rf /usr/share/linux-helper/*.*
	rm -rf /usr/share/linux-helper
	rm -rf /usr/bin/linux-helper-sysctl
	rm -rf /etc/pam.d/linux-helper-sysctl
	rm -rf /etc/security/console.apps/linux-helper-sysctl
	rm -rf /usr/share/applications/linux-helper.desktop

clear:
	rm -rf ./*.o
	rm -rf ./linux-helper
	rm -rf ./linux-helper-sysctl
